#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int n, m;
vector<int> ok;
int stack[10000], top, addres;
void cal(int x, int re_adds) {
	int old = top;
	stack[++top] = x;
	stack[++top] = re_adds;
	stack[++top] = old;
}
int ret() {
	int re_adds = stack[top - 1];
	top = stack[top];
	return re_adds;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	cal(1, 0);
	while (top) {
		int x = stack[top - 2];
		switch (addres)
		{
		case 0:
			if (ok.size() > m || ok.size() + n - x + 1 < m) {
				addres = ret();
				continue;
			}
			if (x == n + 1) {
				for (int i = 0; i < ok.size(); i++)
				{
					cout << ok[i] << ' ';
				}
				cout << "\n";
			}
			cal(x + 1, 1);
			addres = 0;
			continue;
		case 1: 
			ok.push_back(x);
			cal(x + 1, 2);
			addres = 0;
			continue;
		case 2:
			ok.pop_back();
			addres = ret();
		}
	}
	return 0;
}